//
//  InvestorChooseTableViewCell.m
//  BigToBig
//
//  Created by 毛丽媛 on 16/8/8.
//  Copyright © 2016年 cn.cloudtp. All rights reserved.
//

#import "InvestorChooseTableViewCell.h"

@interface InvestorChooseTableViewCell ()
@end

@implementation InvestorChooseTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView{
    self.person = [[UIButton alloc] init];
    [self.person setImage:[UIImage imageNamed:@"xuanzhong"] forState:UIControlStateSelected];
    [self.person setImage:[UIImage imageNamed:@"weixuanzhong"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.person];
    
    self.personLab = [[UILabel alloc] init];
   
    self.personLab.textColor = [UIColor lightGrayColor];
    self.personLab.font = [UIFont systemFontOfSize:13];
    self.personLab.text = @"个人投资";
    [self.contentView addSubview:self.personLab];
    
    self.jigou = [[UIButton alloc] init];
    [self.jigou setImage:[UIImage imageNamed:@"xuanzhong"] forState:UIControlStateSelected];
    [self.jigou setImage:[UIImage imageNamed:@"weixuanzhong"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.jigou];
    
    self.jigoutou = [[UILabel alloc]init];
    [self.contentView addSubview:self.jigoutou];
    self.jigoutou.textColor = [UIColor lightGrayColor];
    self.jigoutou.font = [UIFont systemFontOfSize:13];
    self.jigoutou.text = @"机构投资";
    
    [self.person addTarget:self action:@selector(time1:) forControlEvents:UIControlEventTouchUpInside];
    self.person.tag = 1000;
    [self.jigou addTarget:self action:@selector(time1:) forControlEvents:UIControlEventTouchUpInside];
    self.jigou.tag = 1001;
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.person.frame = CGRectMake(kScreenWidth - 185, self.contentView.frame.size.height / 2 - 12, 24, 24);
    self.personLab.frame = CGRectMake(kScreenWidth - 165, self.contentView.frame.size.height / 2 - 15, 55, 30);
    self.jigou.frame = CGRectMake(kScreenWidth - 110, self.contentView.frame.size.height / 2 - 12, 24, 24);
    self.jigoutou.frame = CGRectMake(kScreenWidth - 80, self.contentView.frame.size.height / 2 - 15, 55, 30);
    if (self.isSelected == 1000) {
        [self time1:self.person];
    }
    else if(self.isSelected == 1001){
        [self time1:self.jigou];
    }
}
- (void)time1:(UIButton *)btn{


        if (self.isSelected == 0) {
            btn.selected = !btn.selected;
            self.isSelected = btn.tag;
        }
        else{

            if (btn.tag == self.isSelected) {
                btn.selected = YES;
                return;
            }
            else{
                if (btn.tag == 1000) {
                    btn.selected = !btn.selected;
                    self.jigou.selected = !self.jigou.selected;
                    self.isSelected = 1000;
                }
                else{
                    btn.selected = !btn.selected;
                    self.person.selected = !self.jigou.selected;
                    self.isSelected = 1001;
                }

            }
        }
    [self.investorChooseCellDelegate changeSelectedWithSelected:self.isSelected];
        
    
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
